package middle;

public class Solution_334 {

    public static void main(String[] args) {
        Solution_334 model = new Solution_334();
//        System.out.println(model.increasingTriplet(new int[]{1, 2, 3, 4, 5}));
//        System.out.println(model.increasingTriplet(new int[]{5,4,3,2,1}));
//        System.out.println(model.increasingTriplet(new int[]{2,1,5,0,4,6}));
        System.out.println(model.increasingTriplet(new int[]{2,1,5,0,6}));
        System.out.println(model.increasingTriplet(new int[]{2}));
    }

    public boolean increasingTriplet(int[] nums) {
        Integer first = null, second = null;
        for (int i = 0; i < nums.length; i++) {
            if (second != null && second < nums[i]) {
                return true;
            }
            if (first != null) {
                if (nums[i] > first) {
                    second = nums[i];
                } else if (nums[i] < first) {
                    first = nums[i];
                }
            } else {
                first = nums[i];
            }
        }
        return false;
    }
}
